//
//  WebViewController.m
//  ios-test
//
//  Created by Apple -11 on 15/10/17.
//  Copyright (c) 2015年 Apple -11. All rights reserved.
//

#import "WebViewController.h"

@interface WebViewController (){
    //UIActivityIndicatorView *activityIndicator;
}

@end

@implementation WebViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    titleLabel.text=@"URl";
    //创建URL
    NSURL *url=[NSURL URLWithString:@"http://www.baidu.com"];
    
    NSURL *url2=[NSURL URLWithString:@"http://moximoxisusan@163.com"];
    //创建NSURLRequest
    NSURLRequest *request=[NSURLRequest requestWithURL:url];
    NSURLRequest *request2=[NSURLRequest requestWithURL:url2];
    
    [self.webView loadRequest:request];
    [self.webInformationView loadRequest:request2];
    
    self.webView.delegate=self;
    self.webInformationView.delegate=self;
}
-(IBAction)exitTo:(id)sender{
    [self dismissViewControllerAnimated:YES completion:nil];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
//网页开始时调用
-(void)webViewDidStartLoad:(UIWebView *)webView{
//    UIView *view=[[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
//    [view setTag:108];
//    [view setBackgroundColor:[UIColor blackColor]];
//    [view setAlpha:0.5];
//    [self.view addSubview:view];
//
//    activityIndicator =[[UIActivityIndicatorView alloc]initWithFrame:CGRectMake(0.0f, 0.0f,32.0f, 32.0f)];
//    [activityIndicator setCenter:view.center];
//    [activityIndicator setActivityIndicatorViewStyle:UIActivityIndicatorViewStyleWhite];
    [SVProgressHUD show];
}
//网页出错
-(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error{
//    UIView *view=(UIView *)[self.view viewWithTag:108];
//    [view removeFromSuperview];
//    NSLog(@"webViewDidFinishLoad");
    [SVProgressHUD showErrorWithStatus:@"加载错误"];
    
}
//成功加载
-(void)webViewDidFinishLoad:(UIWebView *)webView{
//    [activityIndicator stopAnimating];
//    UIView *view=(UIView *)[self.view viewWithTag:108];
//    [view removeFromSuperview];
//    NSLog(@"webViewDidFinishLoad");
    [SVProgressHUD dismiss];
    NSLog(@"webViewDidFinishLoad");
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
